package com.mz361.stdapi.repository;

import com.mz361.modules.system.repository.BaseRepository;
import com.mz361.stdapi.domain.StandardNotice;
import com.mz361.stdapi.domain.StandardNoticeObj;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

/**
 * @author niceale
 * @date 2023/12/06
 */
public interface StandardNoticeRepository extends BaseRepository<StandardNotice, Long> {

    StandardNotice getStandardNoticeByStandardNoticeNo(String standardNoticeNo);

    @Query(value = "SELECT new com.mz361.stdapi.domain.StandardNoticeObj(e.standardNoticeNo,e.noticeType,e.title,e.publishUnit,e.publishDate) FROM StandardNotice e where e.noticeType=?1")
    Page<StandardNoticeObj> findProjectedEntities(String standardType, Pageable pageable);

    @Query(value = "SELECT new com.mz361.stdapi.domain.StandardNoticeObj(e.standardNoticeNo,e.noticeType,e.title,e.publishUnit,e.publishDate) FROM StandardNotice e where e.noticeType=?1 and e.title like  ?2")
    Page<StandardNoticeObj> findProjectedEntitiesLikeKeyword(String standardType, String keyWord, Pageable pageable);

}